package com.forekenow.Demo11;

import java.util.*;

public class ListMapDemo {
    public static void main(String[] args) {

        Student student = new Student();
        student.setName("小明");
        student.setAge(2);
        student.setId(1);
        Student student1 = new Student();
        student1.setName("小红");
        student1.setAge(2);
        student1.setId(5);
        Student student2 = new Student();
        student2.setName("小绿");
        student2.setAge(2);
        student2.setId(3);

        Map<String,Student> maps = new HashMap<>();
        maps.put("第一名",student);
        Map<String,Student> maps1 = new HashMap<>();
        maps1.put("第二名",student1);
        Map<String,Student> maps2 = new HashMap<>();
        maps2.put("第三名",student2);

        List<Map<String,Student>> list = new ArrayList<>();
        list.add(maps);
        list.add(maps1);
        list.add(maps2);


        for (int i = 0; i < list.size(); i++) {
            Map<String,Student> map = list.get(i);
            //对map集合进行遍历
            Set<Map.Entry<String,Student>> it = map.entrySet();
            Iterator<Map.Entry<String, Student>> iterator = it.iterator();
            while (iterator.hasNext()){
                Map.Entry<String,Student> entry =  iterator.next();
                String key = entry.getKey();
                Student v = entry.getValue();
                System.out.println(key+"---"+v.getName()+"----"+v.getAge());
            }
        }

    }
}
